package cn.stylefeng.guns.modular.demos.data;

import cn.hutool.http.HttpRequest;
import cn.stylefeng.guns.modular.order.entity.StorageTaskXlb;
import cn.stylefeng.roses.core.util.ToolUtil;
import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class DataAsyc {


    public static void main(String[] args) {
        String url = "https://hxl-api.xlbsoft.com/api/hxl.open.wms.pickOrder.find";
        String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOltudWxsXSwidXNlcl9uYW1lIjoiYWRtaW4iLCJPcGVuLUNvbXBhbnktVHlwZSI6Ik9wZW4tQXBpIiwiQ29tcGFueV9JZCI6NjY2NjYsInNjb3BlIjpbInJlYWQiXSwiZXhwIjoxNzM3MjIzMjAxLCJhdXRob3JpdGllcyI6WyJyb2xlX2RldiJdLCJqdGkiOiJVaEJ4M1VfS0JXSjhMTktIYnduWFlJaU5NSkEiLCJjbGllbnRfaWQiOiI3ZmExMTAxZTU5NTk0MTg5OTE3ZWM3MGUzNjdkYjk4NCJ9.ZvYz1hwHG5WPFEWaCDDhCRBZ-L2Hrzn46M0Cd0qcXWzEjyR3X1GwgXsV3kpzhColUCDVN47SuXzJtAFUV6V0ifHbPFEiy_O4xGQ7uH6rBG6qeGUYt3E0R6vGNkQDl9cLeCJcvzEMZ5f_fVDJyb-dwilBkhUyiEaIjYycdN1t4iWB_nIlSLumKjB0WLrsklmaprATxi82i9xXFCliLdWFSCXtWk5hKfoBxQ8kmYFIrPl1mQ7GD-FXO0wrN_7OwgoGl1yLFzeuRIp3Cd0fe0mMLtEU7wTN1kCYoPuDS2Be-fqDZMcq7GgF9FTpiEftMVZ__4V7avazc3DeVED2gGAfIg";
        List<String> pick_finish_time = new ArrayList<String>();
        pick_finish_time.add("2025-01-17 12:40:00");
        pick_finish_time.add("2025-01-17 12:58:00");
        JSONObject json = new JSONObject();
        json.put("store_id", "6866800000001");
        json.put("pick_finish_time", pick_finish_time);
        String post = HttpRequest.post(url)
                .header("Authorization", "bearer " + token).body(json.toString()).execute().body();
        JSONObject jsonObject = new JSONObject(post);
        if (jsonObject.get("code").toString().equals("0")) {
            List<StorageTaskXlb> xlbs = new ArrayList<StorageTaskXlb>();
            JSONArray jsonArray = new JSONArray(jsonObject.get("data").toString());
            for (Object object : jsonArray) {
                JSONObject jsonObject2 = new JSONObject(object.toString());
                StorageTaskXlb xlb = new StorageTaskXlb();

                String fid = jsonObject2.get("fid").toString().replaceAll("\t\r\n", "");
                if (ToolUtil.isNotEmpty(fid) && !fid.equals("null")) {//单据号
                    xlb.setFid(fid);
                } else {
                    continue;
                }

                String volume = jsonObject2.get("volume").toString();
                if (ToolUtil.isNotEmpty(volume)) {//体积
                    xlb.setVolume(volume);
                }

                System.out.println(fid+":"+volume);
            }
        }
    }
}
